package com.xcalendar.service.rest.impl;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;

import com.xcalendar.database.dao.UserDAO;
import com.xcalendar.database.table.User;

@Path("/c2dm/")
public class C2DMResource {
	@GET
	@Produces({ "application/json" })
	@Path("/add/userName={userName}&registrationID={registrationID}/")
	public String getUser(@PathParam("userName") String userName, @PathParam("registrationID") String registrationID) {
		User userTemp = new User();
		userTemp.setUserName(userName);
		UserDAO userDAO = new UserDAO();
		User user = userDAO.readUser(userTemp);
		if(user == null) return "error";
		
		user.setRegistrationID(registrationID);
		userDAO.updateUserRegisterId(user);
		return "ok";
	}
}
